﻿//-----------------------------------------------------------------------------------------
// <copyright file="Slider.cs" company="Jakub Florczyk (www.jakubflorczyk.pl)">
//      Copyright © 2009 Jakub Florczyk (www.jakubflorczyk.pl)
//      http://samsungmobilesdknet.codeplex.com
// </copyright>
//-----------------------------------------------------------------------------------------

namespace SamsungMobileSDKNET
{
    using System.Runtime.InteropServices;

    /// <summary>
    /// Pointer to function that handles slider events. The current state is passed in as a parameter.
    /// </summary>
    /// <param name="state">Slider state.</param>
    public delegate void SliderEventHandler(SliderState state);

    /// <summary>
    /// Slider states.
    /// </summary>
    public enum SliderState
    {
        /// <summary>
        /// Closed state.
        /// </summary>
        Closed,

        /// <summary>
        /// Open state.
        /// </summary>
        Open
    }

    /// <summary>
    /// Samsung Slider API.
    /// </summary>
    /// <remarks>
    /// The Samsung Slider API enables applications to determine if a slider phone's keyboard is opened or closed.
    /// </remarks>
    public class Slider
    {        
        /// <summary>
        /// Gets the current state of slider.
        /// </summary>
        /// <param name="state">Pointer to an initialized SmiSliderState object.</param>
        /// <returns>
        /// <see cref="F:SamsungMobileSDKNET.ResultCode.Success"/> on success
        /// <br/>
        /// <see cref="F:SamsungMobileSDKNET.ResultCode.ErrorInvalidParameter"/> if the input parameter is NULL
        /// <br/>
        /// <see cref="F:SamsungMobileSDKNET.ResultCode.ErrorDeviceNotFound"/> if the device does not have a slider keyboard 
        /// </returns>
        [DllImport(Common.DllName, EntryPoint = "SmiSliderGetState")]
        public static extern ResultCode GetState(
            [Out] out SliderState state);

        /// <summary>
        /// Registers a callback handler to be called whenever the slide state changes. A client can only register one handler per process.
        /// </summary>
        /// <param name="handler">Pointer to function that will handle the event</param>
        /// <returns>
        /// <see cref="F:SamsungMobileSDKNET.ResultCode.Success"/> on success
        /// <br/>
        /// <see cref="F:SamsungMobileSDKNET.ResultCode.ErrorInvalidParameter"/> if the input parameter is NULL
        /// <br/>
        /// <see cref="F:SamsungMobileSDKNET.ResultCode.ErrorDeviceNotFound"/> if the device does not have a slider keyboard
        /// </returns>
        [DllImport(Common.DllName, EntryPoint = "SmiSliderRegisterOnChangeHandler")]
        public static extern ResultCode RegisterOnChangeHandler(
            [In] SliderEventHandler handler);

        /// <summary>
        /// Unregisters the handler registered by a previous call to the <see cref="M:SamsungMobileSDKNET.Slider.RegisterOnChangeHandler"/> function.
        /// </summary>
        /// <returns>
        /// <see cref="F:SamsungMobileSDKNET.ResultCode.Success"/> on success
        /// <br/>
        /// <see cref="F:SamsungMobileSDKNET.ResultCode.ErrorDeviceNotFound"/> if the device does not have a slider keyboard
        /// </returns>
        [DllImport(Common.DllName, EntryPoint = "SmiSliderUnregisterOnChangeHandler")]
        public static extern ResultCode UnregisterOnChangeHandler();
    }
}
